package com.example.controller;

import com.example.entity.Cart;
import com.example.service.CartService;
import com.example.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/cart")
public class CartController {

    @Autowired
    private CartService cartService;

    @PostMapping("/listCart")
    public Result listCart(@RequestBody Cart cart) {
        List<Cart> carts = cartService.listCart(cart);
        return Result.ok(carts);
    }

    @PostMapping("/saveCart")
    public Result saveCart(@RequestBody Cart cart) {
        cartService.saveCart(cart);
        return Result.ok();
    }

    @RequestMapping("/removeCart")
    public Result removeCart(@RequestBody Cart cart) {
        cartService.removeCart(cart);
        return Result.ok();
    }

}
